/**
 * com.oceansoft.mobile.econsole.modules.weixin.controller.WechatH5ApiController
 *
 * @author chenw
 * @create 16/2/4.16:54
 * @email javacspring@hotmail.com
 */

package com.oceansoft.mobile.econsole.modules.weixin.controller;

import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.weixin.service.IWechatH5ApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 微信H5页面后台接口
 *
 * @author chenw
 * @create 16/2/4 16:54
 * @email javacspring@gmail.com
 */
@RestController
@RequestMapping("api/wechat/v1")
public class WechatH5ApiController {

    private final Logger logger = LoggerFactory.getLogger(getClass());
    private static final Marker MARKER_API = MarkerFactory.getMarker("wechat.api");

    @Resource
    private IWechatH5ApiService wechatH5ApiService;

    @RequestMapping("complain")
    public Result clueReport(@RequestParam("uid") String userId,
                             @RequestParam("name") String userName,
                             @RequestParam("subject") String subject,
                             @RequestParam("content") String content,
                             @RequestParam("anonymous") int anonymous) {
        boolean rt = wechatH5ApiService.saveComplaint(userId, userName, subject, content, anonymous);
        logger.debug(MARKER_API, "\nSubject={},Content={},PublishType={}", subject, content, anonymous);
        if (rt) {
            return new Result("提交成功");
        } else {
            return new Result("提交失败");
        }
    }


}
